/**
*      author: Y_Yao
*      created: 2024-11-30 16:43:48
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 5e4 + 7;
int a[N],dp[N],res[N];

bool cmp(int x1,int x2)
{
    return x1 >= x2;
}

void solve()
{
    vector<int> v1,v2;
    int x;
    while(cin >> x)
    {
        //求上升子序列的个数
        auto it = lower_bound(v1.begin(),v1.end(),x,cmp);
        if(it != v1.end())
        {
            v1[it - v1.begin()] = x;
        }
        else
        {
            v1.push_back(x);
        }
        // for(auto e : v1)
        // {
        //     cout << e << " ";
        // }
        // cout << endl;

        //求下降序列的个数
        it = lower_bound(v2.begin(),v2.end(),x);
        if(it != v2.end())
        {
            v2[it - v2.begin()] = x;
        }
        else
        {
            v2.push_back(x);
        }
    }

    cout << v1.size() << endl;
    cout << v2.size() << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}